
package com.pp.admin.main.client.common;

import com.google.gwt.event.dom.client.ClickHandler;
import com.pp.admin.common.client.helper.AdminButton;
import com.pp.admin.common.client.helper.Resource;

public class CrudOnListPage extends CrudOp {
	
	private AdminButton	create	= null;
	
	private AdminButton	delete	= null;
	
	public CrudOnListPage() {

		create = new AdminButton( myConstants.create(), Resource.CREATE_IMG_URL );
		delete = new AdminButton( myConstants.delete(), Resource.DELETE_IMG_URL );
		add( create );
		add( delete );
	}
	
	public void addCreateClickHandler( ClickHandler handler ) {

		create.addClickHandler( handler );
	}
	
	public void addDeleteClickHandler( ClickHandler handler ) {

		delete.addClickHandler( handler );
	}
	
	public void disableDeleteAction() {

		delete.setEnabled( false );
		delete.setImageURL( Resource.DISABLE_DELETE_IMG_URL );
	}
	
	public void enableDeleteAction() {

		delete.setImageURL( Resource.DELETE_IMG_URL );
		delete.setEnabled( true );
	}
	
	public void refreshState() {

		if ( !delete.isEnabled() ) {
			enableDeleteAction();
		}
	}
}
